<% form_tag :controller => 'employee', :action => 'list_employees', :method => 'get' do %>
		<%= text_field_tag :search, params[:search], :id => 'search_field' %>
		<%= submit_tag "Search", :name => nil %>
		<%= link_to_function "Clear", "$('search_field').clear()" %>
<% end %>
<table id="employee_table" class="tablesorter">
<thead>
    <tr>
      <th>
        Employee name
      </th>
      <th>
      	Phone
      </th>
      <th>
      	Email
      </th>
      <th>
      	Is a manager
      </th>

    </tr>
</thead>
<tbody>
<% for employee in @employees %>
  <tr>
    <td>
	  <%= h(employee.first_name) + " " + h(employee.last_name) %>
	</td><td>
	  <% if employee.phone && employee.phone.length == 10 %>
	     (<%= h(employee.phone[0..2]) %>)&nbsp;&nbsp;<%= h(employee.phone[3..5]) %>&nbsp;-&nbsp;<%= h(employee.phone[6..9]) %>
	  <% else %>
	    <%= h(employee.phone) %>
	  <% end %>
	</td><td>
	  <a href="mailto:<%= h(employee.email) %>"><%= h(employee.email) %></a>
	</td>
	<td>
		<% if employee.is_manager %>
		yes
		<%else%>
		no
		<%end%>
	</td>
	<% if @employee.is_manager %>
	<td style="text-align:center">
	  <%= link_to "Edit", {:action => "edit_employee", :id => employee} %>	  
    </td><td style="text-align:center">
      <%= link_to "Delete", {:action => "delete_employee", :id => employee}, {:method => :post, :confirm => "Confirm removal of #{employee.first_name} #{employee.last_name}"} %>      
    </td>
	<%end%>
</tr>
<% end %>
</tbody>
</table>
<script type="text/javascript">
    $("#employee_table").tablesorter();
</script>
